<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('order', function (Blueprint $table) {
            $table->decimal('price', 10)->default(0)->comment("价格")->after('category');
        });

        Schema::create('charge_product', function (Blueprint $table) {
            $table->id();
            $table->unsignedTinyInteger('is_disabled')->default(0)->comment("禁用");
            $table->decimal('price', 10)->default(0)->comment("价格");
            $table->integer('ticket')->default(0)->comment("获得次数");
            $table->unsignedSmallInteger('order')->default(999)->comment("排序");
            $table->timestamps();
        });
        DB::statement("ALTER TABLE `charge_product` COMMENT='充值价格表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('charge_product');
        Schema::table('order', function (Blueprint $table) {
            $table->dropColumn(['price']);
        });
    }
};
